<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="http://unpkg.com/view-design/dist/styles/iview.css">
    <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>
    <script type="text/javascript" src="http://unpkg.com/view-design@4.0.2/dist/iview.min.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>消息:{{message}}</p> 
        <div>
            <my-component></my-component>

        </div>
    </div>
    <script>
        var bus = new Vue();

        Vue.component('my-component',{
            template:"<div><button @click='handleEvent'>传递事件</button><div>",
            methods:{
                handleEvent:function(){
                   bus.$emit('on-message','来自组件的内容');
                },
            }
        })

        new Vue({
            el:"#app",
            data:{
                message:''
            },
            mounted:function(){
                var _self = this;
                bus.$on('on-message',function(msg){
                    _self.message = msg;
                })
            }
        })

    </script>
</body>
</html>